﻿@{
    ViewBag.Title = "UserRegisterPhone";
    Layout = "~/Views/Shared/MasterView.cshtml";
}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.validate.min.js"> </script>
<link type="text/css" rel="stylesheet" href="/pc/themes/base.css">
<link type="text/css" rel="stylesheet" href="/pc/themes/ceng.css">
<link type="text/css" rel="stylesheet" href="/pc/themes/Safe.css">
<link rel="stylesheet" type="text/css" href="/pc/themes/util.css" />
<script>
    var Error = 0;
    function TestPhonepwd()
    {
        if ($("#Phone").val() != "") {
            if (!(/^1[34578]\d{9}$/.test($("#Phone").val()))) {
                $("#SPhone").html("输入的手机号不符合格式");
                $("#SPhone").css("color", "red");
            }
            else {
                $("#SPhone").html("√");
                $("#SPhone").css("color", "green");
            }
        }
        else
        {
            $("#SPhone").html("请输入手机号码");
            $("#SPhone").css("color", "red");
        }
        
    }
    var code = 0;
    function GetPhonePwd()
    {
        if ($("#Phone").val() != "") {
            if (!(/^1[34578]\d{9}$/.test($("#Phone").val()))) {
                $("#SPhone").html("输入的手机号不符合格式");
                $("#SPhone").css("color", "red");
                Error = 1;
            }
            else {
                $.ajax({
                    url: "/SecurityCenter/GetPhonePwd",
                    type: "post",
                    data: {
                        Phone: $("#Phone").val()
                    },
                    success: function (mes) {
                        if (mes != 0) {
                            code = mes;
                            var btn = $("#GetPhonepwd");
                            var count = 60;
                            var resend = setInterval(function () {
                                count--;
                                if (count > 0) {
                                    btn.val(count + "秒后重获取");
                                    $.cookie("captcha", count, { path: '/', expires: (1 / 86400) * count });
                                } else {
                                    clearInterval(resend);
                                    btn.val("获取验证码").removeAttr('disabled style');
                                }
                            }, 1000);
                            btn.attr('disabled', true).css('cursor', 'not-allowed');
                        }
                        else {
                            alert("系统异常")
                        }

                    }
                })
            }
        }
        else {
            $("#SPhone").html("请输入手机号码");
            $("#SPhone").css("color", "red");
        }
        
    }
    function TestCode()
    {
        if ($("#code").val()=="")
        {
            $("#SCode").html("请输入验证码")
            $("#SCode").css("color", "red")
        }
        else
        {
            if ($("#code").val() != code)
            {
                $("#SCode").html("验证码不正确请重新输入")
                $("#SCode").css("color", "red");
            }
            else
            {
                $("#SCode").html("√")
                $("#SCode").css("color", "green")
            }
           
        }
    }
    function BinDingPhone()
    {
        if ($("#code").val() == "") {
            $("#SCode").html("请输入验证码")
            $("#SCode").css("color", "red")
            Error = 1;
        }
        else {
            if ($("#code").val() != code) {
                $("#SCode").html("验证码不正确请重新输入")
                $("#SCode").css("color", "red");
                Error = 1;
            }
            else {
                $.post("/SecurityCenter/BinDingUserPhone", { Phone: $("#Phone").val() }, function (mes) {
                    if (mes != 0)
                    {
                        location.href = '/Myaccount/SecurityCenter';
                    }
                    else {
                        alert("系统异常")
                        location.reload();
                    }
                })
            }

        }
    }
</script>
<div class="content" id="hongman">
    <!--当流程没完成时 li的class值为“hui”+步骤数值,当流程完成是li的class值为“hong”--->
    <div class="Bind">
        <style type="text/css">
            .span_lf {
                margin: 20px 0 20px 150px;
            }
                .span_lf .txt_180 
                {
                    width: 322px;
                }

                .span_lf .txt_80 {
                    width: 178px;
                }

                .span_lf .but_jb {
                    margin-left: 5px;
                    width: 140px;
                }
        </style>
        <div class="path_safe"><span><a href="/security">安全中心</a></span><em>&gt;</em><span>绑定手机</span></div>
        <div class="clear"></div>
        <div style="" class="span_lf">
            <ul>
                <li><span class="sp_1">手机号码：</span><span>&nbsp;<input type="text" onblur="TestPhonepwd()" id="Phone" value="" size="20" maxlength="11" placeholder="请输入有效的手机号码" /></span><span id="SPhone"></span></li>
                <li><span class="sp_1">验证码：</span><span>&nbsp;<input type="text" id="code" name="code" class="txt_80" onblur="TestCode()" /><input type="button" class="btn-primary" onclick="GetPhonePwd()" id="GetPhonepwd" value="获取验证码" /></span><span id="SCode"></span></li>
                <li id="tip" ></li>
            </ul>
            <div class="clear"></div>
            <p style=" margin:10px 0 0 150px;"><input type="button" id="ConmitBtn"  value="确  定" class="Flat_but" onclick="BinDingPhone()" /></p>
            <div class="clear"></div>
        </div>
    </div>
</div>
